"use strict";
const electron = require("electron");
const path = require("node:path");
let win;
const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"];
process.env.DIST = path.join(__dirname, "../dist");
process.env.PUBLIC = electron.app.isPackaged ? process.env.DIST : path.join(process.env.DIST, "../public");
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
function createWindow() {
  win = new electron.BrowserWindow({
    frame: false,
    // 关闭默认标题栏
    transparent: true,
    // 窗口是否支持透明，如果想做高级效果最好为true
    width: 1100,
    minWidth: 1100,
    // 宽度
    height: 720,
    minHeight: 720,
    // 高度
    hasShadow: false,
    // 阴影
    icon: path.join("../public", "vite.svg"),
    // 图标
    backgroundColor: "#00000000",
    // 背景色
    webPreferences: {
      preload: path.join(__dirname, "preload.js"),
      webSecurity: true,
      //  渲染进程 开启node模块，使得JS中可以使用node的model
      nodeIntegration: true,
      // 控制上下文隔离
      contextIsolation: false,
      devTools: true
      //关闭开发者工具
    }
  });
  if (VITE_DEV_SERVER_URL) {
    win.loadURL(VITE_DEV_SERVER_URL).then(() => {
    });
  } else {
    win.loadFile(path.join(process.env.DIST, "index.html")).then(() => {
    });
  }
}
electron.ipcMain.on("window-min", () => {
  win == null ? void 0 : win.minimize();
});
electron.ipcMain.on("window-close", () => {
  win == null ? void 0 : win.close();
});
electron.app.whenReady().then(createWindow);
